import Gobj from "./Gobj";
import GMap from "./GMap";
import GUniverse from "./GUniverse";
import GTower from "./GTower";

export default class GPlayer extends Gobj{

    monsterMap = new GMap();
    towerMap   = new GMap();
    bulletMap  = new GMap();

    syncTime(other:Gobj){
        super.syncTime(other);

        var oplayer = other as GPlayer;
        this.monsterMap.syncTime(this.uid , oplayer.monsterMap );
        this.towerMap.syncTime(this.uid , oplayer.towerMap );
        this.bulletMap.syncTime(this.uid , oplayer.bulletMap );
    }

    timeline(sf:number , lf:number , fms:number , keyf:boolean , u:GUniverse,ac:any){
        var arr = this.monsterMap.objArr.concat();
        for (let i = 0; i < arr.length; i++) {
            const e = arr[i];
            e.timeline(sf, lf, fms, keyf, u, ac);
        }

        var arr = this.bulletMap.objArr.concat();
        for (let i = 0; i < arr.length; i++) {
            const e = arr[i];
            e.timeline(sf, lf, fms, keyf, u, ac);
        }

        var arr = this.towerMap.objArr.concat();
        for (let i = 0; i < arr.length; i++) {
            const e = arr[i];
            e.timeline(sf, lf, fms, keyf, u, ac);
        }
    }
    
}